﻿namespace PMS.Client.FrmUserLeave
{
    using PMS.BLL;
    using PMS.Common;
    using PMS.Model;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    public class FrmLeave : Form
    {
        private Button btnCancel;
        private Button btnSave;
        private IContainer components = null;
        private Label label1;
        private Label label2;
        private Label label24;
        private Label label25;
        private Label label26;
        private Label label3;
        private Label label45;
        private Label label51;
        private Label lbTitle;
        private DateTimePicker leaveDay;
        private ComboBox LeaveReasion;
        private TextBox leaveTo;
        private UserChangeLogBLL logbll = new UserChangeLogBLL();
        private DateTimePicker txtDate;
        private TextBox txtNo;
        private TextBox txtRemark;
        private TextBox txtSummary;
        private TextBox txtUsername;
        private UserBLL userbll = new UserBLL();
        private int userid = 0;

        public FrmLeave(int userid)
        {
            this.InitializeComponent();
            this.userid = userid;
            User model = this.userbll.GetModel(userid);
            this.txtUsername.Text = model.UserName;
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            base.Close();
        }

        private void btnSave_Click(object sender, EventArgs e)
        {
            UserChangeLog log2 = new UserChangeLog {
                IsLeave = 1,
                LeaveDay = new DateTime?(this.leaveDay.Value),
                LeaveTo = this.leaveTo.Text,
                LeaveReasion = this.LeaveReasion.Text,
                LeaveNo = this.txtNo.Text,
                LeaveDate = new DateTime?(this.txtDate.Value),
                LeaveSummary = this.txtRemark.Text,
                LeaveRemark = this.txtRemark.Text,
                UserID = this.userid,
                CheckState = "未审核",
                LogType = "减少",
                UpdateDate = new DateTime?(DateTime.Now),
                UpdateUser = PMS.Common.Keys.Admin.LoginName
            };
            UserChangeLog model = log2;
            try
            {
                if (this.logbll.Add(model) > 0)
                {
                    MessageBox.Show("减少成功，等待审核中！");
                    base.DialogResult = DialogResult.OK;
                    base.Close();
                }
                else
                {
                    MessageBox.Show("减少失败！");
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("修改失败！错误：" + exception.Message);
            }
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            ComponentResourceManager manager = new ComponentResourceManager(typeof(FrmLeave));
            this.leaveDay = new DateTimePicker();
            this.label45 = new Label();
            this.txtUsername = new TextBox();
            this.label2 = new Label();
            this.leaveTo = new TextBox();
            this.label1 = new Label();
            this.txtDate = new DateTimePicker();
            this.label3 = new Label();
            this.txtRemark = new TextBox();
            this.label26 = new Label();
            this.txtSummary = new TextBox();
            this.label25 = new Label();
            this.txtNo = new TextBox();
            this.label24 = new Label();
            this.LeaveReasion = new ComboBox();
            this.label51 = new Label();
            this.btnCancel = new Button();
            this.btnSave = new Button();
            this.lbTitle = new Label();
            base.SuspendLayout();
            this.leaveDay.CalendarMonthBackground = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.leaveDay.Location = new Point(140, 0x81);
            this.leaveDay.Name = "leaveDay";
            this.leaveDay.Size = new Size(200, 0x15);
            this.leaveDay.TabIndex = 0x62;
            this.label45.AutoSize = true;
            this.label45.Location = new Point(0x51, 0x87);
            this.label45.Name = "label45";
            this.label45.Size = new Size(0x35, 12);
            this.label45.TabIndex = 0x61;
            this.label45.Text = "减少时间";
            this.txtUsername.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.txtUsername.BorderStyle = BorderStyle.FixedSingle;
            this.txtUsername.Enabled = false;
            this.txtUsername.Location = new Point(140, 0x31);
            this.txtUsername.Name = "txtUsername";
            this.txtUsername.ReadOnly = true;
            this.txtUsername.Size = new Size(200, 0x15);
            this.txtUsername.TabIndex = 90;
            this.label2.AutoSize = true;
            this.label2.Location = new Point(0x39, 0x33);
            this.label2.Name = "label2";
            this.label2.Size = new Size(0x4d, 12);
            this.label2.TabIndex = 0x59;
            this.label2.Text = "减少人员姓名";
            this.leaveTo.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.leaveTo.BorderStyle = BorderStyle.FixedSingle;
            this.leaveTo.Location = new Point(140, 0x66);
            this.leaveTo.Name = "leaveTo";
            this.leaveTo.Size = new Size(200, 0x15);
            this.leaveTo.TabIndex = 100;
            this.label1.AutoSize = true;
            this.label1.Location = new Point(0x39, 0x68);
            this.label1.Name = "label1";
            this.label1.Size = new Size(0x4d, 12);
            this.label1.TabIndex = 0x63;
            this.label1.Text = "减少人员去向";
            this.txtDate.CalendarMonthBackground = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.txtDate.Location = new Point(140, 0xb7);
            this.txtDate.Name = "txtDate";
            this.txtDate.Size = new Size(200, 0x15);
            this.txtDate.TabIndex = 0x6c;
            this.label3.AutoSize = true;
            this.label3.Location = new Point(0x51, 0xbb);
            this.label3.Name = "label3";
            this.label3.Size = new Size(0x35, 12);
            this.label3.TabIndex = 0x6b;
            this.label3.Text = "下文时间";
            this.txtRemark.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.txtRemark.BorderStyle = BorderStyle.FixedSingle;
            this.txtRemark.Location = new Point(140, 0xee);
            this.txtRemark.Multiline = true;
            this.txtRemark.Name = "txtRemark";
            this.txtRemark.Size = new Size(0x12d, 0x58);
            this.txtRemark.TabIndex = 0x6a;
            this.label26.AutoSize = true;
            this.label26.Location = new Point(0x69, 0xee);
            this.label26.Name = "label26";
            this.label26.Size = new Size(0x1d, 12);
            this.label26.TabIndex = 0x69;
            this.label26.Text = "备注";
            this.txtSummary.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.txtSummary.BorderStyle = BorderStyle.FixedSingle;
            this.txtSummary.Location = new Point(140, 210);
            this.txtSummary.Name = "txtSummary";
            this.txtSummary.Size = new Size(200, 0x15);
            this.txtSummary.TabIndex = 0x68;
            this.label25.AutoSize = true;
            this.label25.Location = new Point(0x69, 0xd5);
            this.label25.Name = "label25";
            this.label25.Size = new Size(0x1d, 12);
            this.label25.TabIndex = 0x67;
            this.label25.Text = "摘要";
            this.txtNo.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.txtNo.BorderStyle = BorderStyle.FixedSingle;
            this.txtNo.Location = new Point(140, 0x9c);
            this.txtNo.Name = "txtNo";
            this.txtNo.Size = new Size(200, 0x15);
            this.txtNo.TabIndex = 0x66;
            this.label24.AutoSize = true;
            this.label24.Location = new Point(0x69, 0x9e);
            this.label24.Name = "label24";
            this.label24.Size = new Size(0x1d, 12);
            this.label24.TabIndex = 0x65;
            this.label24.Text = "文号";
            this.LeaveReasion.BackColor = Color.FromArgb(0xd9, 0xea, 0xf7);
            this.LeaveReasion.FlatStyle = FlatStyle.Flat;
            this.LeaveReasion.FormattingEnabled = true;
            this.LeaveReasion.ItemHeight = 12;
            this.LeaveReasion.Items.AddRange(new object[] { "请选择", "调出机关", "调出事业", "调出企业", "调任机关", "调任事业", "离休", "退休", "辞职", "辞退", "亡故", "其他" });
            this.LeaveReasion.Location = new Point(140, 0x4c);
            this.LeaveReasion.Name = "LeaveReasion";
            this.LeaveReasion.Size = new Size(200, 20);
            this.LeaveReasion.TabIndex = 110;
            this.label51.AutoSize = true;
            this.label51.Location = new Point(0x51, 0x4f);
            this.label51.Name = "label51";
            this.label51.Size = new Size(0x35, 12);
            this.label51.TabIndex = 0x6d;
            this.label51.Text = "减少原因";
            this.btnCancel.BackColor = Color.White;
            this.btnCancel.FlatStyle = FlatStyle.Popup;
            this.btnCancel.Location = new Point(0x109, 0x15c);
            this.btnCancel.Name = "btnCancel";
            this.btnCancel.Size = new Size(0x4b, 0x17);
            this.btnCancel.TabIndex = 0x70;
            this.btnCancel.Text = "关闭";
            this.btnCancel.UseVisualStyleBackColor = false;
            this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
            this.btnSave.BackColor = Color.White;
            this.btnSave.FlatStyle = FlatStyle.Popup;
            this.btnSave.Location = new Point(140, 0x15c);
            this.btnSave.Name = "btnSave";
            this.btnSave.Size = new Size(0x4b, 0x17);
            this.btnSave.TabIndex = 0x6f;
            this.btnSave.Text = "保存";
            this.btnSave.UseVisualStyleBackColor = false;
            this.btnSave.Click += new EventHandler(this.btnSave_Click);
            this.lbTitle.BackColor = Color.Gold;
            this.lbTitle.Dock = DockStyle.Top;
            this.lbTitle.Font = new Font("宋体", 14.25f, FontStyle.Bold, GraphicsUnit.Point, 0x86);
            this.lbTitle.ForeColor = Color.Black;
            this.lbTitle.Location = new Point(0, 0);
            this.lbTitle.Name = "lbTitle";
            this.lbTitle.Size = new Size(0x1e7, 0x1f);
            this.lbTitle.TabIndex = 0x71;
            this.lbTitle.Text = "人员减少";
            this.lbTitle.TextAlign = ContentAlignment.MiddleCenter;
            base.AutoScaleDimensions = new SizeF(6f, 12f);
            base.AutoScaleMode = AutoScaleMode.Font;
            this.BackColor = Color.FromArgb(0xa4, 0xc4, 0xeb);
            base.ClientSize = new Size(0x1e7, 0x17f);
            base.Controls.Add(this.lbTitle);
            base.Controls.Add(this.btnCancel);
            base.Controls.Add(this.btnSave);
            base.Controls.Add(this.LeaveReasion);
            base.Controls.Add(this.label51);
            base.Controls.Add(this.txtDate);
            base.Controls.Add(this.label3);
            base.Controls.Add(this.txtRemark);
            base.Controls.Add(this.label26);
            base.Controls.Add(this.txtSummary);
            base.Controls.Add(this.label25);
            base.Controls.Add(this.txtNo);
            base.Controls.Add(this.label24);
            base.Controls.Add(this.leaveTo);
            base.Controls.Add(this.label1);
            base.Controls.Add(this.leaveDay);
            base.Controls.Add(this.label45);
            base.Controls.Add(this.txtUsername);
            base.Controls.Add(this.label2);
            base.FormBorderStyle = FormBorderStyle.FixedSingle;
            base.Icon = (Icon) manager.GetObject("$this.Icon");
            base.MaximizeBox = false;
            base.MinimizeBox = false;
            base.Name = "FrmLeave";
            base.StartPosition = FormStartPosition.CenterScreen;
            this.Text = "减少人员";
            base.ResumeLayout(false);
            base.PerformLayout();
        }
    }
}

